﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>奔驰用户注册</title>
    <script src="~/Scripts/jquery-1.8.2.js"></script>
</head>
<body>
    <form>
        用户帐号：<input id="txt_username" type="text" /><br />
        用户密码：<input id="txt_password" type="password" /><br />
        重复密码：<input id="txt_repassword" type="password" /><br />
        <input id="btn_register" type="button" value="注册" />
    </form>
    <script type="text/javascript">
        $("#btn_register").click(function () {
            var username = $("#txt_username").val();
            var flag = (username == "" || username.replace(/\s/g, "") == "");
            if (flag) {
                alert("用户帐号不能为空");
                return;
            }
            var password = $("#txt_password").val();
            if (password == "") {
                alert("用户密码不能为空");
                return;
            }
            var repassword = $("#txt_repassword").val();
            if (repassword == "") {
                alert("重复密码不能为空");
                return;
            }
            if (password != repassword) {
                alert("两次输入的密码不一致");
                return;
            }

            $.ajax({
                type: "Put",
                url: "/api/ssoapi/0?repassword=" + repassword,
                data: { username: username, password: password },
                dataType: "Json",
                async: false,
                success: function (objInvokeResult) {
                    alert(objInvokeResult.ResultMessage);
                    if (objInvokeResult.ResultCode == "Success") {
                        window.location.href = "/user/createredirect?callback=@Request["callback"]&userId=" + objInvokeResult.Data;
                    }
                }
            });
        });
    </script>
</body>
</html>
